<?php namespace App\Services\Admin;

use App\Facades\Infra\Admin\WechatDoctorManage;
use App\Models\WeChatDoctorInfo;

class WechatDoctorService{

	public function getWechatDoctors(){
		return WechatDoctorManage::getWechatDoctors()->paginate(10);
	}

	public function getWechatDoctor($data){

		$conditions['id'] =$data['id'];

		return WechatDoctorManage::getWechatDoctors($conditions)->first();
	}

	public function getDoctorType(){
		return WeChatDoctorInfo::$DRTYPE;
	}

	public function getQRCode($wechatDoctor){
		
		$wechat = app('wechat');

		$qrcode = $wechat->qrcode;


		if(count($wechatDoctor->wechatDoctorInfo)!=0){
			$ticker = $wechatDoctor->wechatDoctorInfo->ticket;

			return $qrcode->url($ticker);
		}
		
		return;
	}

	public function getTheUsers($data){
		$conditions['form_openid'] =$data['openid'];

		return WechatDoctorManage::getTheWechatUsers($conditions)->paginate(10);
	}

}